#Boa:Frame:ConvenioFrame

import wx
from BancoDeDados import *
bd = BancoDeDados()

def create(parent):
    return ConvenioFrame(parent)

[wxID_CONVENIOFRAME, wxID_CONVENIOFRAMEADICIONAR, wxID_CONVENIOFRAMECHOICE1, 
 wxID_CONVENIOFRAMECONVENIO, wxID_CONVENIOFRAMEESPCONVENIO, 
 wxID_CONVENIOFRAMEEXCLUIR, wxID_CONVENIOFRAMEPANEL1, 
 wxID_CONVENIOFRAMESTATICBOX1, wxID_CONVENIOFRAMESTATICTEXT1, 
] = [wx.NewId() for _init_ctrls in range(9)]

class ConvenioFrame(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_CONVENIOFRAME, name='ConvenioFrame',
              parent=prnt, pos=wx.Point(416, 382), size=wx.Size(449, 175),
              style=wx.DEFAULT_FRAME_STYLE, title='Fonte de Renda')
        self.SetClientSize(wx.Size(433, 137))

        self.panel1 = wx.Panel(id=wxID_CONVENIOFRAMEPANEL1, name='panel1',
              parent=self, pos=wx.Point(0, 0), size=wx.Size(433, 137),
              style=wx.TAB_TRAVERSAL)

        self.EspConvenio = wx.TextCtrl(id=wxID_CONVENIOFRAMEESPCONVENIO,
              name='EspConvenio', parent=self.panel1, pos=wx.Point(112, 24),
              size=wx.Size(192, 21), style=0, value='')

        self.adicionar = wx.Button(id=wxID_CONVENIOFRAMEADICIONAR,
              label='Adicionar', name='adicionar', parent=self.panel1,
              pos=wx.Point(328, 24), size=wx.Size(75, 23), style=0)
        self.adicionar.Bind(wx.EVT_BUTTON, self.OnAdicionarButton,
              id=wxID_CONVENIOFRAMEADICIONAR)

        self.choice1 = wx.Choice(choices = bd.get_lista_convenios(), id=wxID_CONVENIOFRAMECHOICE1,
              name='choice1', parent=self.panel1, pos=wx.Point(112, 56),
              size=wx.Size(192, 21), style=0)

        self.excluir = wx.Button(id=wxID_CONVENIOFRAMEEXCLUIR, label='Excluir',
              name='excluir', parent=self.panel1, pos=wx.Point(328, 56),
              size=wx.Size(75, 23), style=0)
        self.excluir.Bind(wx.EVT_BUTTON, self.OnExcluirButton,
              id=wxID_CONVENIOFRAMEEXCLUIR)

        self.staticBox1 = wx.StaticBox(id=wxID_CONVENIOFRAMESTATICBOX1,
              label='Conv\xeanio', name='staticBox1', parent=self.panel1,
              pos=wx.Point(0, 0), size=wx.Size(432, 152), style=0)

        self.staticText1 = wx.StaticText(id=wxID_CONVENIOFRAMESTATICTEXT1,
              label=u'Pesquisar:', name='staticText1', parent=self.panel1,
              pos=wx.Point(8, 56), size=wx.Size(60, 16), style=0)
        self.staticText1.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))

        self.convenio = wx.StaticText(id=wxID_CONVENIOFRAMECONVENIO,
              label='Conv\xeanio', name='convenio', parent=self.panel1,
              pos=wx.Point(8, 24), size=wx.Size(52, 16), style=0)
        self.convenio.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              u'Tahoma'))

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OnAdicionarButton(self, event):
        bd.adicionar_convenio(self.EspConvenio.GetValue())
        self.EspConvenio.SetValue('')
    def OnExcluirButton(self, event):
        bd.excluir_convenio(self.choice1.GetLabel())
